package com.yanqu.road.entity.activity.apprentice;

import com.yanqu.road.utils.string.StringUtils;

import java.util.*;

public class ApprenticeProgramResult {

    /**
     * 增加的天资值MAP
     */
    private Map<Integer, ApprenticeTalentData> talentDataMap = new LinkedHashMap<>();

    /**
     * specialProjectIds : 特殊项目效果IDS
     */
    private List<ApprenticeEffectBuffProject> specialProjectIds = new ArrayList<>();


    /**
     * reward : 奖励
     */
    private String reward;

    public Map<Integer, ApprenticeTalentData> getTalentDataMap() {
        return talentDataMap;
    }

    public void addTalentData(ApprenticeTalentData addTalentData) {
        ApprenticeTalentData talentData = talentDataMap.computeIfAbsent(addTalentData.getType(), k -> new ApprenticeTalentData(addTalentData.getType(), 0));
        talentData.addValue(addTalentData.getValue());
    }

    public List<ApprenticeEffectBuffProject> getSpecialProjectIds() {
        return specialProjectIds;
    }

    public void setSpecialProjectIds(List<ApprenticeEffectBuffProject> specialProjectIds) {
        this.specialProjectIds = specialProjectIds;
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    /**
     * 天资奖励转字符串
     * @return
     */
    public String talentRerawdToString() {
        List<String> list = new ArrayList<>();
        for (ApprenticeTalentData data : this.getTalentDataMap().values()) {
            list.add(data.talentToString());
        }
        return StringUtils.listToString(list, ",");
    }

    /**
     * 生效特殊项目转字符串
     * @return
     */
    public String specialProjectToString() {
        List<Integer> list = new ArrayList<>();
        for (ApprenticeEffectBuffProject data : this.getSpecialProjectIds()) {
            list.add(data.getProjectId());
        }
        return StringUtils.listToString(list, ",");
    }
}
